//
//  MineTaskCell.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/8.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "MineTaskCell.h"

@interface MineTaskCell ()

@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *detailLabel;
@property(nonatomic, strong)UIButton *rightButton;
@property(nonatomic, strong)UIView *centerView;

@end

@implementation MineTaskCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString * identifier = @"MineTaskCell";
    MineTaskCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[MineTaskCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        
        self.centerView = [[UIView alloc]init];
        [self addSubview:self.centerView];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont xm_font:15.0];
        self.titleLabel.textColor = [UIColor xm_colorFromRGB:0x212832];
        [self addSubview:self.titleLabel];
        
        self.detailLabel = [[UILabel alloc]init];
        self.detailLabel.font = [UIFont xm_font:12.0];
        self.detailLabel.textColor = [UIColor xm_colorFromRGB:0x858C96];
        [self addSubview:self.detailLabel];
        
        self.rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.rightButton.titleLabel.font = [UIFont xm_font:13.0];
        [self.rightButton setTitleColor:[UIColor xm_MainColor] forState:UIControlStateNormal];
        self.rightButton.clipsToBounds = YES;
        self.rightButton.layer.cornerRadius = 30.0/2;
        self.rightButton.layer.borderColor = [UIColor xm_MainColor].CGColor;
        self.rightButton.layer.borderWidth = 1.0;
        [self addSubview:self.rightButton];

        [self.rightButton setTitle:@"立即邀请" forState:UIControlStateNormal];
        self.titleLabel.text = @"邀请好友";
        self.detailLabel.text = @"邀请一名好友可得 20 火球币";
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    [self.centerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(100, 8));
        make.left.mas_equalTo(self).offset(20);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.centerView);
        make.bottom.mas_equalTo(self.centerView.mas_top);
    }];
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.centerView);
        make.top.mas_equalTo(self.centerView.mas_bottom);
    }];
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(72, 30));
        make.right.mas_equalTo(self).offset(-15);
    }];
}

@end
